import com.myc.UserMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.List;
import java.util.Map;

/**
 * @Classname MybatisTest
 * @Description
 * @Date 2020-09-03 17:26
 * @Created by myc
 */
public class MybatisTest {
    public static void main(String[] args) throws Exception {
        String resource = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory =
                new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession session = sqlSessionFactory.openSession();
        UserMapper userMapper = session.getMapper(UserMapper.class);
        List<Map<String,Object>> list= userMapper.selectAll();

        Map<String,Object> user = userMapper.selectById(1,"18658170800");
        System.out.println(list.get(0));
        System.out.println(user);
    }
}
